package ua.javatr.android.smb;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

public class MainActivity extends Activity implements DialogFragmentAddCard.OnDataCompleteListener, CardListFragment.OnCardSelectedListener {

    DialogFragmentAddCard dac;

    /**
     * Called when the activity is first created.
     *
     * @param savedInstanceState If the activity is being re-initialized after
     *                           previously being shut down then this Bundle contains the data it most
     *                           recently supplied in onSaveInstanceState(Bundle). <b>Note: Otherwise it is null.</b>
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_main);

//        if (карт нет){
//        dac = new DialogAddCard();
//        dac.show(getFragmentManager(), "dlg1");}


//        getActionBar().setTitle("Список карт");
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(ua.javatr.android.smb.R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == R.id.action_settings) {
            Intent intent = new Intent(getApplicationContext(), SettingsActivity.class);
            startActivity(intent);
        }
        if (item.getItemId() == R.id.smsactivty){
            Intent intent = new Intent(getApplicationContext(),SmsSendActivity.class);
            startActivity(intent);
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onDataComplete(String cardNumber, String cardName, String bankName) {
//        (cardName + " " + String.valueOf(cardNumber) + " " + bankName);
    }

    @Override
    public void onCardSelected(String cardNumber) {
        Toast.makeText(this, cardNumber, Toast.LENGTH_SHORT).show();
        Intent intent = new Intent(this,CardMenuActivity.class);
        intent.putExtra("Header","Карта для выплат 01234 5678 9101 1121");
        startActivity(intent);
    }
}


